package controllers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import models.EEntity;

public class OrderEntityByViews implements Comparator<EEntity> {

	@Override
	public int compare(EEntity u1, EEntity u2) {
		if(u1.numberOfView < u2.numberOfView)
			return -1;
		if(u1.numberOfView > u2.numberOfView)
			return 1;
		return 0;
	}


	public static void sort(ArrayList<EEntity> entities){
		Collections.sort(entities, new OrderEntityByViews());
	}

}
